/***************************************************************************
    scro - ???
    Copyright (C) 2004 Stefan Zidar

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to Free Software 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
    Stefan Zidar
    AUSTRIA
    steffed@gmx.net
****************************************************************************

****************************************************************************
* scro.c - the main source file (you must compile this!)                   *
*               please read also the readme file.                          *
****************************************************************************/

#include "scro.hxx"
#include "SDL_collide.hxx"
#include "utils.hxx"
#include "level.hxx"
#include "settings.hxx"
#include "execbasic.hxx"
#include "sdlfunc.hxx"
#include "game.hxx"

/* declarations of variables starts here */
yakwailog logger;

SDL_Surface *slFont;
//SFont_Font *selFont;

SDL_Rect playerRect;

Object objectArray[MAX_OBJECTS];

SDL_Surface *screen;
SDL_Surface *badguy;
SDL_Surface *fire;

SDL_Event event;

char health = 100;

Environment scro;
/* declarations of variables ends here */

/* main function */
int main(int argNum, char *argA[])
{
	scro.execPath = new char [strlen(argA[0]) + 1];
	// TODO: initialize global vars...
	strncpy(scro.execPath, argA[0], strlen(argA[0]));
	getCleanExecPath(scro.execPath);
	scro.tempChar = new char [strlen(argA[0]) + 52];
	
	if (strlen(scro.execPath) == 0) sprintf(scro.execPath, "./");
	sprintf(scro.tempChar, "%s/scro.log", scro.execPath);
	logger.init((char*)"scro", scro.tempChar, DEFAULT_LOGLEVEL);
	logger.log(0, "starting up %s.", SCRO_VERSION);
	restoreDefaults();
	loadSettings();
	handleArgs(argNum, argA);
	if (initEnv((char*) SCRO_TITLE, XMAX, YMAX, VIDEO_BITS, VIDEO_MODE) == 0) quitScro(-1);
	setControls();
	logger.log(0, "start-up completed, running...");
	gameEngine();
	quitScro(1);
	return 0;
}

